﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PFAGame
{
    class TemplateScreen : MenuScreen
    {
        MenuEntry unusedEntry;
        MenuEntry healthEntry;
        MenuEntry damageEntry;
        MenuEntry attackSpeedEntry;
        MenuEntry moveSpeedEntry;
        MenuEntry resistEntry;

        public TemplateScreen()
            : base("Skill tree")
        {
            unusedEntry = new MenuEntry("");
            healthEntry = new MenuEntry("");
            damageEntry = new MenuEntry("");
            attackSpeedEntry = new MenuEntry("");
            moveSpeedEntry = new MenuEntry("");
            resistEntry = new MenuEntry("");
            MenuEntry exitMenuEntry = new MenuEntry("return");

            unusedEntry.Selected += showUnused;
            healthEntry.Selected += upHealth;
            damageEntry.Selected += upDamage;
            attackSpeedEntry.Selected += upAttackSpeed;
            moveSpeedEntry.Selected += upMoveSpeed;
            resistEntry.Selected += upResist;
            exitMenuEntry.Selected += OnCancel;

            MenuEntries.Add(unusedEntry);
            MenuEntries.Add(healthEntry);
            MenuEntries.Add(damageEntry);
            MenuEntries.Add(attackSpeedEntry);
            MenuEntries.Add(moveSpeedEntry);
            MenuEntries.Add(resistEntry);
            MenuEntries.Add(exitMenuEntry);

            updateStrings();
        }

        void updateStrings()
        {
            unusedEntry.Text = "Point Left: " + GameplayScreen.Singleton.Players[0].UnusedTemplate;
            healthEntry.Text = "health: " + GameplayScreen.Singleton.Players[0].HealthTemplate;
            damageEntry.Text = "Damage: " + GameplayScreen.Singleton.Players[0].DamageTemplate;
            attackSpeedEntry.Text = "Attack speed: " + GameplayScreen.Singleton.Players[0].AttackSpeedTemplate;
            moveSpeedEntry.Text = "Move speed: " + GameplayScreen.Singleton.Players[0].MoveSpeedTemplate;
            resistEntry.Text = "Resist: " + GameplayScreen.Singleton.Players[0].ResistTemplate;
        }

        void showUnused(object sender, PlayerIndexEventArgs e)
        {
            updateStrings();
        }

        void upHealth(object sender, PlayerIndexEventArgs e)
        {
            GameplayScreen.Singleton.Players[0].upHealth(false);
            updateStrings();
        }

        void upDamage(object sender, PlayerIndexEventArgs e)
        {
            GameplayScreen.Singleton.Players[0].upDamage(false);
            updateStrings();
        }

        void upAttackSpeed(object sender, PlayerIndexEventArgs e)
        {
            GameplayScreen.Singleton.Players[0].upAttackSpeed(false);
            updateStrings();
        }

        void upMoveSpeed(object sender, PlayerIndexEventArgs e)
        {
            GameplayScreen.Singleton.Players[0].upMoveSpeed(false);
            updateStrings();
        }

        void upResist(object sender, PlayerIndexEventArgs e)
        {
            GameplayScreen.Singleton.Players[0].upResist(false);
            updateStrings();
        }
    }
}
